# -*- coding: utf-8 -*-

import py_global

import logging

logger = logging.getLogger(__name__)


class TestClass(object):

    def __init__(self, *args, **kwargs):
        self.attr = 'class'

    def class_method(self):
        logger.info(f'TestClass attr:{self.attr}')
        pass

    pass


class TestMixin(object):

    def __init__(self, *args, **kwargs):
        self.attr = 'mixin'

    def mixin_method(self):
        logger.info(f'TestMixin attr:{self.attr}')
        pass

    def class_method(self):
        # 先调用Mixin类中的方法
        self.mixin_method()
        # super()会根据类的__mrd__去匹配
        return super().class_method()

    pass


class TestMixinClass(TestMixin, TestClass):
    pass


class TestClassMixin(TestClass, TestMixin):
    pass


if __name__ == '__main__':
    """
    注意多继承时Mixin类在前面
    """
    test_mixin_class = TestMixinClass()
    test_mixin_class.class_method()

    test_class_mixin = TestClassMixin()
    test_class_mixin.class_method()

    pass
